//
//  RootViewController.m
//  Travel assistant
//
//  Created by 杨帆 on 16/2/27.
//  Copyright © 2016年 旅游助手. All rights reserved.
//

#import "RootViewController.h"

#import "ToolViewController.h"
#import "JourneyTVController.h"
#import "FindViewController.h"
#import "MineViewController.h"


@interface RootViewController ()

@end

@implementation RootViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    /**
     *  添加子控制器
     */
    [self addAllChildViewControllers];

}

/**
 *  初始化所有子控制器
 */
- (void)addAllChildViewControllers{
    
    ToolViewController *toolVC = [ToolViewController new];
    
    [self addChildViewController:toolVC Title:@"工具箱" ImageName:@"tool" SelectedImage:nil];
    
    JourneyTVController *journeyVC = [JourneyTVController new];
    
    [self addChildViewController:journeyVC Title:@"行程" ImageName:@"journey" SelectedImage:nil];
    
    FindViewController *findVC = [FindViewController new];
    
    [self addChildViewController:findVC Title:@"发现" ImageName:@"find" SelectedImage:nil];
    
    MineViewController *mineVC = [MineViewController new];
    
    [self addChildViewController:mineVC Title:@"我的" ImageName:@"mine" SelectedImage:nil];
    
    
    
}




/**
 *  初始化子控件
 *
 *  @param childVC       需要初始化的自控制器
 *  @param title         标题
 *  @param imageName     图片
 *  @param selectedImage 选中后的图片
 */
- (void)addChildViewController:(UIViewController *)childVC Title:(NSString *)title ImageName:(NSString *)imageName SelectedImage:(NSString *)selectedImage
{
    
    
    childVC.tabBarItem = [[UITabBarItem alloc]initWithTitle:title image:[UIImage imageNamed:imageName] selectedImage:[UIImage imageNamed:selectedImage]];
    
    UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:childVC];
    
    [self addChildViewController:nav];
    
}






- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
